package com.tansun.easycare.rule.serialno.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.tansun.easycare.rule.exception.BizException;
import com.tansun.easycare.rule.serialno.dao.RuleSerialNoDAO;
import com.tansun.easycare.rule.serialno.service.RuleSerialNoService;

@Service("ruleSerialNoService")
public class RuleSerialNoServiceImpl implements RuleSerialNoService {

    @Autowired
    private RuleSerialNoDAO ruleSerialNoDAO;

    @Override
    public String generalCodeByType(String type, String projectCode) throws BizException {
        Long serNo = this.ruleSerialNoDAO.generateSerialNo(type, projectCode);
        String sResult = "00000000000";
        String strSerNo = String.valueOf(serNo);
        sResult = type + sResult.substring(0, sResult.length() - strSerNo.length());
        return sResult + strSerNo;
    }

}
